package java_thinking.unit_19._19_1_6;

import static common.util.Print.print;
import static common.util.Print.printnb;

/**
 * @Desc:   演示Enum提供的一些功能
 * @author: cww
 * @DateTime: 2019-05-21 22:39
 */
enum Shrubbery {
    GROUND, CRAWLING, HANGING
}
/**
 * @author asd730520@live.com
 */
public class EnumClass {
    public static void main(String[] args) {
        for (Shrubbery s : Shrubbery.values()) {
            //ordinal 返回一个int，每个enum在声明时的次序，从0开始
            print(s + " ordinal: " + s.ordinal());
            printnb(s.compareTo(Shrubbery.CRAWLING) + " ");
            print(s == Shrubbery.CRAWLING);
            print(s.getDeclaringClass());
            print(s.name());
            print("-----------------");
        }
        for (String s : "HANGING CRAWLING GROUND".split(" ")) {
            Shrubbery shrubbery = Enum.valueOf(Shrubbery.class, s);
            print(shrubbery);
        }
    }
}
